package com.it2297.view;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;

import com.it2297.controller.CustomerController;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class DeleteCustomerView extends JPanel {
	private final CustomerController dcv = new CustomerController(this);
	private final JLabel lblDeleteCustomer = new JLabel("Terminate Customer Record");
	private final JLabel lblUsernamenric = new JLabel("Username (NRIC ) Of Customer");
	private final JTextField nric_TF = new JTextField();
	private final JButton btnTerminate = new JButton("Confirm ");

	/**
	 * Create the panel.
	 */
	public DeleteCustomerView() {
		nric_TF.setBounds(234, 112, 157, 20);
		nric_TF.setColumns(10);

		initGUI();
	}
	private void initGUI() {
		setLayout(null);
		lblDeleteCustomer.setFont(new Font("Arial", Font.BOLD, 15));
		lblDeleteCustomer.setBounds(24, 25, 333, 33);
		
		add(lblDeleteCustomer);
		lblUsernamenric.setFont(new Font("Arial", Font.PLAIN, 12));
		lblUsernamenric.setBounds(40, 105, 179, 33);
		
		add(lblUsernamenric);
		
		add(nric_TF);
		btnTerminate.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(nric_TF.getText().equals("")){
					JOptionPane.showMessageDialog(null,"Please enter a nric!");
				}
				else{
				dcv.delete();
				nric_TF.setText("");
				}
			}
		});
		btnTerminate.setFont(new Font("Arial", Font.PLAIN, 12));
		btnTerminate.setBounds(171, 212, 89, 23);
		
		add(btnTerminate);
	}
	
	public String getNric() {
		return nric_TF.getText();
	}
}

